package org.teremail.smtp.commands;

import java.util.List;

import org.teremail.smtp.SMTPSession;

import com.google.common.collect.ImmutableList;

/**
 * Base class for all SMTP Commands.  Contains a name and a list of parameters.
 * 
 * @author Michael Barker
 *
 */
public abstract class SMTPCommand {

    public final static List<String> EMPTY = ImmutableList.of();
    public static final String MSG_OK = "250 OK";
    public static final String MSG_503 = "503 Command out of sequence";
    public static final String MSG_554 = "554 No valid recipients";

    private final String name;
    private final List<String> parameters;

    public SMTPCommand(String commandName, List<String> parameters) {
        this.name = commandName;
        this.parameters = parameters;
    }

    /**
     * The name of the command e.g. HELO, MAIL, etc.
     * 
     * @return
     */
    public String getName() {
        return name;
    }

    /**
     * The parameters that appear after the command (if any).
     * 
     * @return
     */
    public List<String> getParameters() {
        return parameters;
    }

    /**
     * Actually handle the processing of the command.  This method won't return
     * anything.  Output should be written directly to the session.
     * 
     * @param session
     */
    public void process(SMTPSession session) {
        throw new UnsupportedOperationException(getClass().getName() + ".process");
    }

}
